﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ex04
{

    /// <summary>
    /// Avoid subquery
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            var list = new List<string>();
            for (int i = 0; i < 100000; i++)
            {
                list.Add(i.ToString());
            }

            string[] names = list.ToArray();

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            int shortest = names.Min(n => n.Length);
            var list1 = (
                from n in names
                where n.Length == shortest
                select n
            ).ToList();
            //.Dump("No subquery");
            stopwatch.Stop();
            Console.WriteLine(stopwatch.ElapsedMilliseconds);
            Console.ReadKey();
        }
    }
}
